/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.fzhucc.modules.sciPersonnelInfo.repository;

import com.fzhucc.modules.pms.domain.ProjectLargeSmall;
import com.fzhucc.modules.sciPersonnelInfo.domain.SciPersonnelInfoMate;
import com.fzhucc.modules.sciTechnologyDemand.domain.SciTechnologyDemandMate;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
* @website https://eladmin.vip
* @author yyg
* @date 2024-01-08
**/
public interface SciPersonnelInfoMateRepository extends JpaRepository<SciPersonnelInfoMate, Integer>, JpaSpecificationExecutor<SciPersonnelInfoMate> {

    @Query(nativeQuery = true, value = "select * from tb_sci_personnel_info_mate where sp_id=:spId and td_id=:tdId order by matesort")
    List<SciPersonnelInfoMate> findBySpIdTdId(int spId, int tdId);

    @Query(nativeQuery = true, value = "select * from tb_sci_personnel_info_mate where td_id=:tdId order by matesort")
    List<SciPersonnelInfoMate> findByTdId(int tdId);

    @Query(nativeQuery = true, value = "select * from tb_sci_personnel_info_mate where sp_id=:spId order by matesort")
    List<SciPersonnelInfoMate> findBySpId(int spId);

    @Query(nativeQuery = true, value = "select * from tb_sci_personnel_info_mate where sp_id=:spId order by matesort")
    Page<SciPersonnelInfoMate> findBySpIdPage(int spId, Pageable pageable);

    @Query(nativeQuery = true, value = "select * from tb_sci_personnel_info_mate where sp_id=:spId and is_select =1 order by matesort")
    List<SciPersonnelInfoMate> findIsSelect(int spId);


    @Query(nativeQuery = true, value = "SELECT m.* FROM tb_sci_personnel_info_mate as m,tb_sci_technology_demand as d WHERE 1=1 and m.sp_id=:spId and m.td_id=d.id and d.slogan like :name")
    Page<SciPersonnelInfoMate> findAllWithOutParmByLikeMName(int spId,String name,Pageable pageable);
}